/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 * */

// AmzServer - Tototoy's server model.
// Author: tonyjobmails@gmail.com (tonyhack).
//
// Define class CommunicateConfigure.
// 
//

#ifndef __COMMUNICATE__CONFIGURE__H
#define __COMMUNICATE__CONFIGURE__H

#include "compress_interface.h"
#include "encrypt_interface.h"

namespace amz {

enum TCPCommunicateType {
  TCP_COMMUNICATE_TYPE_BUFFER = 0,
  TCP_COMMUNICATE_TYPE_PACKET,

  TCP_COMMUNICATE_TYPE_MAX,  
};

enum UDPCommunicateType {
  UDP_COMMUNICATE_TYPE_STREAM = 0,
  UDP_COMMUNICATE_TYPE_PACKET,

  UDP_COMMUNICATE_TYPE_MAX,  
};

struct TCPCommunicateConfigure {
  TCPCommunicateType type_;
  CompressType compress_;
  EncryptType encrypt_;
  ring_queue_define::RingQueueConfigure configure_;
};

struct UDPCommunicateConfigure {
  UDPCommunicateType type_;
  CompressType compress_;
  EncryptType encrypt_;
  ring_queue_define::RingQueueConfigure configure_;
};

class CommunicateConfigure : public SingletonFactory<CommunicateConfigure> {
  friend SingletonFactory<CommunicateConfigure>;
 public:
  inline uint32 GetUnitMessageSize() const {
    return this->unit_message_size_;
  }
  inline uint32 GetUnitMessagePacketSize() const {
    return this->unit_message_packet_size_;
  }

 private:
  CommunicateConfigure();
  ~CommunicateConfigure();

  uint32 unit_message_size_;
  uint32 unit_message_packet_size_;

  TCPCommunicateConfigure tcp_configure_;
  UDPCommunicateConfigure udp_configure_;
};

}  // namespace amz

#endif  // __COMMUNICATE__CONFIGURE__H

